import random
import matplotlib.pyplot as plt
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif'] = ['SimHei']
dice_counts = {}

for _ in range(100000):
    dice1_result = random.randint(1,6)
    dice2_result = random.randint(1,6)
    total = dicel_result + dice2_result
    if total in dice_counts:
        dice_counts[total] += 1
    else:dice_counts[total] = 1
totals = list(dice_counts.keys())
counts = list(dice_counts.values())
plt.bar(totals,counts)
plt.xlabel('点数组合')
plt.ylabel('次数')
plt.title('两个骰子投掷结果分布')
plt.show()